/* ex: set tabstop=4 shiftwidth=4 expandtab: */
#include <stdio.h>

void
hexdump(unsigned char *buf, int len)
{
	int i, j, k;

	for (i = 0, j = 1, k = 0; i < len; i++) {
		if (j == 1) {
#ifdef DUMP_CODE
			printf("    ");
#else
			printf("%04X: ", k);
			k += 16;
#endif
		}
#ifdef DUMP_CODE
		printf("0x%02X, ", buf[i]);
#else
		printf("%02X ", buf[i]);
		if (j == 4 || j == 8 || j == 12)
			printf(" ");
#endif
		j++;
#ifdef DUMP_CODE
		if (j == 9) {
#else
		if (j == 17) {
#endif
			j = 1;
			printf("\n");
		}
	}
	printf("\n");
}
